package service

import (
	"context"
	__ "mt-server/basic/proto"
	"mt-server/handler/model"
)

// 商家门店展示
func (s *Server) ListMerchant(_ context.Context, in *__.ListMerchantReq) (*__.ListMerchantResp, error) {

	var or model.Merchant

	order, total, _ := or.ListMerchant(in.NikName, int(in.Page), int(in.PageSize))

	var list []*__.GetMerchant

	for _, val := range order {
		list = append(list, &__.GetMerchant{
			Id:      int64(val.Id),
			NikName: val.NikName,
			Rating:  float32(val.Rating),
			Status:  int64(val.Status),
		})
	}

	return &__.ListMerchantResp{
		List:     list,
		Page:     in.Page,
		PageSize: in.PageSize,
		Total:    total,
	}, nil
}
